package com.cube.springtest.controller;


import com.cube.springtest.entity.SysBalance;
import com.cube.springtest.model.Result;
import com.cube.springtest.service.ISysBalanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tweakbunny
 * @since 2021-07-08
 */
@RestController
@RequestMapping("/balance")
@Api(value = "测试接口", tags = "用户管理相关的接口", description = "用户测试接口")
public class SysBalanceController {

    @Autowired
    private ISysBalanceService iSysBalanceService;

    @ApiOperation(value="获取用户列表", notes="")
    @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User")
    @GetMapping(value={"/user"})
    public List<SysBalance> getUserList() {
        List<SysBalance> r = new ArrayList<SysBalance>();
        return r;
    }

    @ApiOperation(value="余额变动", notes="查询所有所有余额信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "name", value = "用户名称", required = false, dataType = "String")
    })
    @GetMapping(value="/getAll")
    public Result getAllBalance(Integer id, String name) {
        return Result.succeed(iSysBalanceService.list(null));
    }

    @ApiOperation(value="获取name的余额列表", notes="")
    @ApiImplicitParam(name = "name", value = "用户名称", required = true, dataType = "String")
    @GetMapping("/query/{name}")
    public Result queryByName(@PathVariable("name") String name){
        List<SysBalance> sysBalances = iSysBalanceService.queryByName(name);
        return Result.succeed(sysBalances);
    }
}
